package com.dingwen.frame.vo;

import com.alibaba.fastjson.JSON;
import com.dingwen.frame.constant.EResultCode;
import com.dingwen.frame.constant.ITipAndMessage;
import lombok.*;

import java.io.Serializable;
import java.sql.Timestamp;


/**
 * 结果
 *
 * @author dingwen
 * @date 2021/05/28
 * @since 1.0.0-SNAPSHOT
 */
@Builder
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {

    private static final long serialVersionUID = -5399051578054163779L;

    /**
     * 代码,默认值200 ok。
     */
    @Builder.Default
    private int code = EResultCode.OK.code();

    /**
     * 消息,默认显示成功
     */
    @Builder.Default
    private String message = ITipAndMessage.SUCCESS;

    /**
     * 数据，默认为null
     */
    @Builder.Default
    private Object data = null;


    /**
     * 当前时间,默认显示当前时间，已通过fast json 格式化
     */
    @Builder.Default
    private Timestamp currentTime = new Timestamp(System.currentTimeMillis());


    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }


}